package cn.com.db.service;

import cn.com.db.model.StoreSurface;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StoreSurfaceService extends BaseService{

    public StoreSurface getStoreSurfaceById(String id){
        return storeSurfaceDao.getStoreSurfaceById(id);
    }

    public StoreSurface getStoreSurfaceOfStore(String storeId,String surfaceId){
        return storeSurfaceDao.getStoreSurfaceOfStore(storeId,surfaceId);
    }

    public Boolean isExist(String id){
        if (StringUtils.isBlank(id)){
            return false;
        }
        return getStoreSurfaceById(id)!=null;
    }

    public Boolean isAlive(String id){
        if (StringUtils.isBlank(id)){
            return false;
        }
        StoreSurface storeSurface=getStoreSurfaceById(id);
        if (storeSurface!=null&&!storeSurface.getDel()){
            return true;
        }
        return false;
    }

    public List<StoreSurface> getStoreSurface(String store,String parent){
        return storeSurfaceDao.getStoreSurface(store,parent);
    }

    public Integer countStoreSurface(String store,String parent){
        return storeSurfaceDao.countStoreSurface(store,parent);
    }

    public void onSurface(StoreSurface storeSurface){
        storeSurfaceDao.createStoreSurface(storeSurface);
    }

    @Transactional
    public void updateSurface(StoreSurface storeSurface){
        storeSurfaceDao.update(storeSurface);
    }

}
